#!/bin/sh
source ${LMD_BASE_INSTALL_SCRIPT_DIR}/global/alias.sh

export CURRENT_APP_PATH=${LMD_APPS_DIR}/ComfyUI
export GIT_DEPTH_PARAM="--depth=1"

if [ -d "$CURRENT_APP_PATH" ]; then
    echo "App Dir: "$CURRENT_APP_PATH
else
    echo "Error, App Dir dose not exist, please install the app first. "$CURRENT_APP_PATH
    exit 1
fi

cd ${CURRENT_APP_PATH}
git pull $GIT_DEPTH_PARAM --force --no-rebase

conda install -y conda-forge::huggingface_hub
pip install -r requirements.txt

echo 'Install ComfyUI-Manager'
cd ${CURRENT_APP_PATH}/custom_nodes
export COMFYUI_MANAGER_DIR=${CURRENT_APP_PATH}/custom_nodes/ComfyUI-Manager
git clone ${GIT_HOST}/ltdrdata/ComfyUI-Manager ${COMFYUI_MANAGER_DIR} ${GIT_DEPTH_PARAM}

cd ${COMFYUI_MANAGER_DIR}

git pull $GIT_DEPTH_PARAM --force --no-rebase
